//index.js
//获取应用实例
var app = getApp()
Page({
  data: {
    motto: 'Hello World',
    userInfo: {},
    contentList:[]
  },
  //事件处理函数
  bindViewTap: function() {
    wx.navigateTo({
      url: '../logs/logs'
    })
  },
  onLoad: function () {
    console.log('onLoad')
    wx.showShareMenu({
      　　withShareTicket: true
 　　})
    var that = this
    //调用应用实例的方法获取全局数据
    app.getUserInfo(function(userInfo){
      //更新数据
      that.setData({
        userInfo:userInfo
      })
    })
    wx.request({
      url: 'http://127.0.0.1:8080/smallapi/article/getArticleByUserId',
      data: { userId: '111112'},
      method: 'POST',
      header: { "content-type": "application/x-www-form-urlencoded" },
      success:function(res){
        console.log(res.data.data);
        that.setData({
          contentList:res.data.data
        })
      },
      fail:function(res){
        console.log("获取失败")
      }
    })
  },
  clickme:function(e){


    this.setData({
      motto:'wangs'
    })
  },
  onShareAppMessage:function(e){
    if (e.from === 'button') {
      // 来自页面内转发按钮
      console.log(e.target)
    }
    return {
      title: '社区小程序',
      path: 'pages/index/index',
      success: function (res) {
        // 转发成功
        console.log("转发成功:" + JSON.stringify(res));
        var shareTickets = res.shareTickets;
        console.log(shareTickets);
        wx.setStorageSync("tickets", shareTickets);
      　　if (shareTickets.length == 0) {
         　　return false;
        　　}

        wx.getShareInfo({
          shareTicket: '我的测试',
          success:function(s){
            console.log('ceshi:' + JSON.stringify(s));
            var encryptedData = res.encryptedData;
         　 var iv = res.iv;
            
          },
          fail:function(e){
            console.log('failceshi:' + JSON.stringify(e));
          }
        })
      },
      fail: function (res) {
        // 转发失败
        console.log("转发失败:" + JSON.stringify(res));
      }
      
    }

  },
  showDetais:function(e){
    console.log(e);
    var cid=e.currentTarget.dataset.id
     wx.navigateTo({
       url: '../details/details?cid='+cid,
     })
  }
})
